<template>
	<view class="mainpadding">
		<u-modal :show="show" cancelColor="#555" confirmColor="#2361FF" :showCancelButton="true" :title="title"
			@cancel="show=false" @confirm="confirm" :confirmText="$t('shezhi.qr')" :cancelText="$t('shezhi.qx')"></u-modal>
			<view class="flexbetween xiahuaxian margin_top" @click="jumpurl('/pages/system/system?type=3')">
				<view class="sanshier xiaohei">{{$t('shezhi.gywm')}}</view>
				<u-icon name="arrow-right" color="#CCCCCC"></u-icon>
			</view>
			<view class="flexbetween xiahuaxian margin_top"  @click="shows=true">
				<view class="sanshier xiaohei">{{$t('shezhi.qchc')}}</view>
				<view class="sanshier xiaohei">{{fileSizeString}}</view>
			</view>
			<!-- <view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages/system/system?type=1')">
				<view class="sanshier xiaohei">用户协议</view>
				<u-icon name="arrow-right" color="#CCCCCC"></u-icon>
			</view>
			<view class="flexbetween xiahuaxian margin_top" @click="jumper('/pages/system/system?type=2')">
				<view class="sanshier xiaohei">隐私政策</view>
				<u-icon name="arrow-right" color="#CCCCCC"></u-icon>
			</view>
			<view class="flexbetween xiahuaxian margin_top" @click="zxshow=true">
				<view class="sanshier xiaohei">注销账号</view>
				<u-icon name="arrow-right" color="#CCCCCC"></u-icon>
			</view> -->
		<view class="gudingdb ffffff mainpadding" @click="show=true">
			<view class="bigbtn">{{$t('shezhi.tcdl')}}</view>
		</view>
		<!-- <u-modal title='警告' :show="zxshow" content="账号注销后，您的系统数据将不再可用。请慎重处理!!!" @confirm="zxconfirm" style='text-align: center;' confirmColor="#999"
			confirmText="确认注销" cancelText="再想想" cancelColor="#2361FF" buttonReverse showCancelButton
			@cancel='zxshow=false'></u-modal> -->
			
		<u-modal :show="shows" showCancelButton confirmColor="#2361FF" @cancel="shows=false" @confirm="qchcconfirm" :confirmText="$t('shezhi.qr')" :cancelText="$t('shezhi.qx')">
			<view class="slot-content color_ling text_weight text">
				{{$t('shezhi.qdqchc')}}
			</view>
		</u-modal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				show: false,
				shows:false,
				title: this.$t('shezhi.qdtczh'),
				zxshow:false,
				qingshaonian:0,
				fileSizeString:"",
			}
		},
		onLoad() {
			this.formatSize()
		},
		methods: {
			formatSize() {
				let that = this;
				uni.getStorageInfo({
					success(res) {
						let size = res.currentSize;
						if (size < 1024) {
							that.fileSizeString = size + ' B';
						} else if (size/1024>=1 && size/1024/1024<1) {
							that.fileSizeString = Math.floor(size/1024*100)/100 + ' KB';
						} else if (size/1024/1024>=1) {
							that.fileSizeString = Math.floor(size/1024/1024*100)/100 + ' M';
						}
					}
				})
			},
			qchcconfirm() {
				this.shows = false;
				this.clearCache()
			},
			// 清楚緩存
			clearCache() {
				let that = this;
				 uni.removeStorageSync("token")
				 uni.removeStorageSync("user_id")
				 uni.removeStorageSync("mapStatus")
				 uni.removeStorageSync("confirmaStatus")
				//重新獲取并显示清除後的緩存大小
				httpRequest.toast(this.$t('shezhi.qccg'))
				setTimeout(() => {
					uni.navigateBack(1)
				}, 1000)
			},
			zxconfirm() {
				this.zxshow = false;
				httpRequest.request('/api/user/zxUser', 'GET', {
				}, false, false, true).then(res => {
					httpRequest.toast(res.msg);
					if(res.code==1){
						uni.removeStorageSync("token")
						uni.removeStorageSync("user_id")
						uni.removeStorageSync("mapStatus")
						uni.removeStorageSync("confirmaStatus")
						setTimeout(() => {
							uni.navigateBack(1)
						}, 1000)
					}
				})
			},
			jumper(url) {
				uni.navigateTo({
					url: url
				})
			},
			confirm() {
				this.show = false;
				uni.clearStorageSync()
				httpRequest.toast(this.$t('shezhi.tccg'))
				setTimeout(() => {
					uni.navigateBack(1)
				}, 1000)
				
			},
		}
	}
</script>

<style>

</style>
